/*
 * @Author: KKKKKK
 * @Date: 2021-01-10 12:08:44
 * @LastEditors: KKKKKK
 * @LastEditTime: 2021-01-10 12:08:44
 */
import axios from './config'
import url from './url'
const baseUrl = process.env.VUE_APP_BASE_URL

/* 文件信息类 */
// 新增文件信息类
const filesCreate = (params) => axios.post(baseUrl + url.files.create, params)

// 删除文件信息类
const filesDelete = (id) => axios.delete(baseUrl + url.files.delete + `/${id}`)

// 修改文件信息类
const filesUpdate = (params, id) => axios.post(baseUrl + url.files.update + `/${id}`, params)

// 获取某个文件信息类
const filesLoad = (id) => axios.get(baseUrl + url.files.load + `/${id}`)

// 获取文件信息类列表
const filesPage = (params) => axios.get(baseUrl + url.files.page, { params })

const filesUploadFile = (params) => axios.post(baseUrl + url.files.uploadFile, params)

// const filesUpload = (params) => axios.post(baseUrl + url.files.upload, params)
const filesUpload = (params) => axios({
    method: 'post',
    url: process.env.VUE_APP_FILE_URL + url.files.upload,
    headers: {
        'Content-Type': 'multipart/form-data'
    },
    data: params
})

export default {
    filesCreate,
    filesDelete,
    filesUpdate,
    filesLoad,
    filesPage,
    filesUploadFile,
    filesUpload,
}